<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [];
        for (let i = 0; i < 20; i++) {
            arr.push(Math.round(Math.random() * 100));
        }


        function insertionSort(arr) {
            for (let i = 0; i < arr.length; i++) {
                let temp = arr[i],
                    j = i;
                while (j > 0 && arr[j-1]>temp) {
                    arr[j] = arr[j-1];
                    j--;
                }
                arr[j] = temp;
            }

            return arr;
        }

        console.log(insertionSort(arr));
    </script>
</body>

</html>